function PageBackendUsers(user, sd, options) {
  this._user = user;
  this._sd = sd;
  this._options = (options) ? options : null;
  
  this._gui = { content: document.getElementById('table2'),
                userNew: document.getElementById('img1')
              };
              
  this._createElements();
};

PageBackendUsers.prototype._createElements = function() {
  var _self = this;
  
  this._gui.userNew.onclick = function() { location.href = '?p=pageasst&t=pagebackenduser&m1=a4&m2=b1';
                                         };
  
  this._loadData();
};

PageBackendUsers.prototype._loadData = function() {
  var tr, td;
  tr = this._gui.content.insertRow(-1);
  td = tr.insertCell(-1);
  td.appendChild(DOMUtils.getLoadingImage());
  
  this._users = null;
  this._retrieveUsers();
};

PageBackendUsers.prototype._verifyData = function() {
  if (this._users) {
    this._updateElements();
  }
};

PageBackendUsers.prototype._retrieveUsers = function() {
  var _self = this;
  new RequestUtils()._read('user', null, null, null, null, null, null, function(result, params) { _self._users = result.data;
                                                                                                  _self._verifyData.call(_self);
                                                                                                }, null);
};

PageBackendUsers.prototype._updateElements = function() {
  var _self = this;
  var unique = new Date().getTime();
  
  DOMUtils.removeTableRows(this._gui.content, 1);
  
  tr = this._gui.content.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.height = '10px'; 
   
  if (this._users.length == 0) {
    tr = this._gui.content.insertRow(-1);
    td = tr.insertCell(-1);
    td.colSpan = 7;
    td.style.textAlign = 'center';
    td.appendChild(document.createTextNode('Empty'));
  }

  for(var i = 0, il = this._users.length; i < il; i++) {
    var user = this._users[i];
    
    tr = this._gui.content.insertRow(-1);
    new GtrUser(i + '_' + unique, tr, user);
    
    var gui = { account: document.getElementById('link' + i + '_' + unique + '1'),
                type: document.getElementById('td' + i + '_' + unique + '1'),
                btnDel: document.getElementById('button' + i + '_' + unique + '1')
              }
    
    gui.account._user = user;
    gui.account.onclick = function() { location.href = '?p=pageasst&t=pagebackenduser&m1=a4&m2=b1&opt=' + MiscUtils.encode(JSON.stringify({ uid: this._user.id }));
                                       return false;
                                     };

    gui.btnDel._user = user;
    gui.btnDel.onclick = function() { new RequestUtils()._write('user', [], [this._user], function() { _self._createElements.call(_self); }, null);
                                      return false;
                                    };
  }
};
